##################################################################
#                                                                #
#  Winpooch : Windows Watchdog                                   #
#  Copyright (C) 2004  Benoit Blanchon                           #
#                                                                #
#  This program is free software; you can redistribute it        #
#  and/or modify it under the terms of the GNU General Public    #
#  License as published by the Free Software Foundation; either  #
#  version 2 of the License, or (at your option) any later       #
#  version.                                                      #
#                                                                #
#  This program is distributed in the hope that it will be       #
#  useful, but WITHOUT ANY WARRANTY; without even the implied    #
#  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR       #
#  PURPOSE.  See the GNU General Public License for more         #
#  details.                                                      #
#                                                                #
#  You should have received a copy of the GNU General Public     #
#  License along with this program; if not, write to the Free    #
#  Software Foundation, Inc.,                                    #
#  675 Mass Ave, Cambridge, MA 02139, USA.                       #
#                                                                #
##################################################################

DEFINES = -DUNICODE -D_UNICODE
DEFINES += -D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500

CFLAGS = -Wall -ggdb $(DEFINES)
LDLIBS = -lwinmm -lwininet -lcomctl32
LDFLAGS = -mwindows

#
# Programs needed
#
CC	= gcc
GREP	= grep -n
LD	= gcc
MKDEP	= gcc -MM $(CFLAGS)
MV	= mv -f
PNG2ICO = png2ico
RC	= windres $(DEFINES)
RM	= rm -f
SED	= sed
STRIP	= strip

#
# Project specific stuffs
#
APPLICATION = Winpooch
APPLICATION_BIN = $(APPLICATION).exe
APPLICATION_SRCS = $(wildcard *.c)
APPLICATION_OBJS = $(patsubst %.c,%.o,$(APPLICATION_SRCS)) Resources.o

#
# Resource specifc stuffs
# 
ICONS = rsrc/alert.ico rsrc/anim0.ico rsrc/anim1.ico rsrc/disabled.ico rsrc/appicon.ico

all : $(APPLICATION_BIN)

clean :
	$(RM) *.o *.d *.c~ *.h~ *.rc~ Makefile~ README~ README_DE~ CHANGELOG~

strip : $(APPLICATION_BIN)
	$(STRIP) $(APPLICATION_BIN)

todo :
	$(GREP) TODO *.c *.h *.rc

$(APPLICATION_BIN) : $(APPLICATION_OBJS)
	$(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@

deps : $(wildcard *.c) 
	$(CC) $(CFLAGS) -MM $^ $ > $@ || $(RM) $@

%.o : %.rc $(ICONS)
	$(RC) -o $@ $<

%.d : %.c
	$(MKDEP) $< > $@.$$$$; \
	$(SED) 's,\($*\)\.o[ :]*,\1.o $@ : ,g'  $@.$$$$ > $@; \
	$(RM) $@.$$$$

#
# Automatic dependencies
#
-include $(APPLICATION_SRCS:.c=.d)

#
# Manual dependencies
#
Resource.o : $(ICONS)

